在昨天以 Traefik 實現反向代理及平衡負載,並且讓所有 worker 節點均能提供對外 http/https 服務。
接下來,使用 keepalived,讓所有 worker 節點以多機熱備方式,以 VIP 對外提供 http/https 服務。
步驟如下:
$ ssh worker1 "
sudo sed -i -e 's/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf ;
sudo sysctl -p ;
sudo apt install keepalived -y ;
"
! Configuration File for keepalived
global_defs {
default_interface enp0s8
}
vrrp_instance VI_1 {
interface enp0s8
state MASTER
virtual_router_id 201
priority 101
nopreempt
unicast_peer {
10.13.13.102
}
virtual_ipaddress {
10.13.13.201
}
authentication {
auth_type PASS
auth_pass PASSWORD
}
}
$ ssh worker1 "
sudo systemctl start keepalived
"